class NadeStunWProj extends FlameTendril;

var() KFMonster StuckTo;
var() float SlowedGroundSpeed, DefaultGroundSpeed, ReduceSpeedTo;
var() bool bSlowPoison;

function Timer()
{
	if (StuckTo != None)
	{
		if(KFGameType(Level.Game).bWaveBossInProgress)
		{
			return;
		}
		//Log("NadeStunWProj.Working"@LifeSpan);
		if (StuckTo.Health <= 0)
			Destroy();
		if (ROLE == ROLE_Authority)
		{
			if (!StuckTo.IsA('EXZombieBoss') && !StuckTo.IsA('ZombieBoss') && !StuckTo.IsA('shZombieBoss_XMAS'))
			{
				StuckTo.bStunned=(LifeSpan >= 0.0);
			}
			
			if (StuckTo.OriginalGroundSpeed > SlowedGroundSpeed)
			{
				if (!StuckTo.IsA('EXZombieBoss') && !StuckTo.IsA('ZombieBoss') && !StuckTo.IsA('shZombieBoss_XMAS'))
				{
					StuckTo.OriginalGroundSpeed=SlowedGroundSpeed;
				}
				else
				{
					StuckTo.OriginalGroundSpeed=DefaultGroundSpeed * FMin(ReduceSpeedTo * 2.0, 1.0);
				}
			}
			if (LifeSpan <= 0.2)
			{
				StuckTo.OriginalGroundSpeed=DefaultGroundSpeed;
			}
		}
	}
}


function SetSpeeds()
{
	local float MovementSpeedDifficultyScale;
	
	//straight from kfmonster
	if( Level.Game.GameDifficulty < 2.0 )
	{
		MovementSpeedDifficultyScale = 0.95;
	}
	else if( Level.Game.GameDifficulty < 4.0 )
	{
		MovementSpeedDifficultyScale = 1.0;
	}
	else if( Level.Game.GameDifficulty < 7.0 )
	{
		MovementSpeedDifficultyScale = 1.15;
	}
	else // Hardest difficulty
	{
		MovementSpeedDifficultyScale = 1.3;
	}

	DefaultGroundSpeed=StuckTo.Default.GroundSpeed * MovementSpeedDifficultyScale;
	SlowedGroundSpeed=DefaultGroundSpeed * ReduceSpeedTo;
}

simulated function Stick(actor HitActor, vector HitLocation)
{
	local KFPlayerReplicationInfo KFPRI;
	local name NearestBone;
	local float dist;
	//Log(Instigator.OwnerName);
	KFPRI=KFPlayerReplicationInfo(Instigator.Controller.PlayerReplicationInfo);
	if( KFPRI!=none && KFPRI.ClientVeteranSkillLevel == 11)
	{
		LifeSpan=5;
	}
	else if( KFPRI!=none && KFPRI.ClientVeteranSkillLevel == 12)
	{
		LifeSpan=7;
	}
	else if( KFPRI!=none && KFPRI.ClientVeteranSkillLevel >= 13)
	{
		LifeSpan=15;
	}
	else
	{
		LifeSpan=0.2;
	}

	StuckTo=KFMonster(HitActor);
	SetSpeeds();
	
	SetPhysics(PHYS_None);

	NearestBone = GetClosestBone(HitLocation, HitLocation, dist , 'CHR_Spine2' , 15 );
	HitActor.AttachToBone(self,NearestBone);
	SetTimer(0.1,true);

}

defaultproperties
{
     Speed=1.000000
     MaxSpeed=1.000000
     Damage=0.000000
     DamageRadius=1.000000
     DrawType=DT_StaticMesh
     StaticMesh=StaticMesh'KF_pickups2_Trip.Supers.MP7_Dart'
     DrawScale=0.010000
}
